package Poker;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class CardList {

        private static final String[] style={"♥","♦","♣","♠"};

        public static List<Card> buycards(){
            List<Card> cardList=new ArrayList<>();
            for (int i = 0; i < style.length; i++) {
                for (int j = 1; j <= 13; j++) {
                    Card card=new Card(style[i],j);
                    cardList.add(card);
                }
            }
            return cardList;
        }

        public static void shuffle(List<Card> cardList){
            Random random=new Random();
            for (int i = cardList.size()-1; i >0 ; i--) {
                int index=random.nextInt(i);
                change(cardList,i,index);
            }
        }

        public static void change(List<Card> list,int p1,int p2){
            Card temp=list.get(p1);
            list.set(p1,list.get(p2));
            list.set(p2,temp);
        }



    public static void main(String[] args) {
        List<Card> cardList=buycards();
        System.out.println(cardList);

        shuffle(cardList);
        System.out.println(cardList);


        List<List<Card>> lists=new ArrayList<>();

        List<Card> p1=new ArrayList<>();
        List<Card> p2=new ArrayList<>();
        List<Card> p3=new ArrayList<>();
        lists.add(p1);
        lists.add(p2);
        lists.add(p3);


        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 3; j++) {
                Card card=cardList.remove(0);
                lists.get(j).add(card);
            }
        }

        System.out.println(p1);
        System.out.println(p2);
        System.out.println(p3);

        System.out.println(cardList);

    }

}
